package com.gorkr.esjd.controller;

import com.gorkr.esjd.service.ElasticsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author gorkr
 * @date 2022/04/08 18:02
 **/
@RestController
public class TestController {

    @Autowired
    ElasticsearchService elasticsearchService;

    /**
     * 查询结果返回
     * @param keyword
     * @return
     */
    @GetMapping("/search/{keyword}/{from}/{size}")
    public List<Map<String ,Object>> searchKeyword(@PathVariable("keyword") String keyword,
                                                   @PathVariable("from") int from ,
                                                   @PathVariable("size") int size) throws IOException {
        List<Map<String, Object>> list = elasticsearchService.searchKeyword(keyword , from , size);

        return list;
    }
}
    